package com.argticling.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.argticling.service.PreferenceService;

@Controller
public class PreferenceController extends MultiActionController {

	@Autowired
	private PreferenceService preferenceService;

    @RequestMapping(value = "/preference/get", method = RequestMethod.GET)
    public ModelAndView getPreferences(@RequestParam(ParamConstants.ARTICLE_PREFERENCE_ID) String articlePreferenceId) {
        preferenceService.getPreferences(articlePreferenceId);
        ModelAndView mav = new ModelAndView("");
		return mav ;
    }

    @RequestMapping(value = "/preference/user/set", method = RequestMethod.POST)
    public ModelAndView setUserPreferences(@RequestParam(ParamConstants.ARTICLE_PREFERENCE_ID) String preferenceId,
    		@RequestParam(ParamConstants.ARTICLE_ID) String articleId,
    		@RequestParam(ParamConstants.USER_ID) String userId) {
        preferenceService.putUserPreference(preferenceId, userId, articleId);
        ModelAndView mav = new ModelAndView("");
		return mav ;
    }

    @RequestMapping(value = "/preference/user/get", method = RequestMethod.GET)
    public ModelAndView getUserPreferences(@RequestParam(ParamConstants.ARTICLE_PREFERENCE_ID) String articlePreferenceId,
    		@RequestParam(ParamConstants.USER_ID) String userId) {
        preferenceService.getUsersPreferences(articlePreferenceId, userId);
        ModelAndView mav = new ModelAndView("");
		return mav ;
    }

    @RequestMapping(value = "/preference/article/set", method = RequestMethod.POST)
    public ModelAndView setArticlePreferences(HttpServletRequest request, HttpServletResponse response) {
    	//TODO
    	ModelAndView mav = new ModelAndView("");
 		return mav ;
    }

    @RequestMapping(value = "/preference/article/get", method = RequestMethod.GET)
    public ModelAndView getArticlePreferences(@RequestParam(ParamConstants.ARTICLE_ID) String articleId) {
        preferenceService.getArticlePreferences(articleId);
        ModelAndView mav = new ModelAndView("");
		return mav ;
    }

    public PreferenceService getService() {
        return preferenceService;
    }

    public void setService(PreferenceService service) {
        this.preferenceService = service;
    }


}
